package cn.edu.dzkd.software.controller;

import cn.edu.dzkd.software.pojo.Risk;
import cn.edu.dzkd.software.service.RiskService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/risk")
public class RiskController {

    @Resource
    private RiskService riskService;

    @RequestMapping(value = "/selectRisks", method = RequestMethod.GET)
    public Map<String, Object> selectRisks(@RequestParam int page,
                                           String riskName,
                                           String riskLevel) {
        return riskService.selectRisks(page, riskName, riskLevel);
    }

    @RequestMapping(value = "/selectAllrisks", method = RequestMethod.GET)
    public Map<String, Object> selectAllrisks() {
        return riskService.selectAllRisks();
    }

    @RequestMapping(value = "/insert", method = RequestMethod.POST)
    public Map<String, Object> insert(@RequestBody Risk risk) {
        return riskService.insert(risk);
    }

    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Map<String, Object> update(@RequestBody Risk risk) {
        return riskService.update(risk);
    }

    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public Map<String, Object> delete(@RequestParam Integer id) {
        return riskService.delete(id);
    }
}
